<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . 
		'/SAGER/model/interfaces/IEmployeeAddressAccessDao.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/interfaces/IConnectionAccessDao.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/factory/ConnectionFactory.php';
	
	error_reporting (E_ALL ^ E_NOTICE);
	
	$debug = $_SESSION['debug'];

	class  MySqlEmployeeAddressAccessDao implements IEmployeeAddressAccessDao {
 		/**
		 * Constructor of the employee address dao
		 */
	 	public function __construct () {}
	
		/**
		 * Creates an employee address
		 */
		public function createEmployeeAddress($employeeAddress) {
			$startDate = $employeeAddress -> getPkStartDate();
			$endDate = $employeeAddress -> getEndDate();
			$ci = $employeeAddress -> getPkFkIdNumberEmployee();
			
			$connection = ConnectionFactory :: getMySqlConnectionAccessDao();
			$conn = $connection -> openConnection();
			
			$query = "INSERT INTO EMPLOYEE_ADDRESS 
						  (pk_start_date, pk_fk_id_place, pk_fk_id_number_employee)
					  VALUES ('$startDate', " . mysql_insert_id() . ", $ci)";
			
			$sentence = mysql_query($query, $conn);
			
			if ($sentence)
				return true;
			
			return false;
		}
	}
?>